package rabbit.flt.plugins.reactor.test;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

public class CancelSubscriber<T> implements Subscriber<T> {

    private int count;

    private Subscription subscription;

    public CancelSubscriber() {
        this(0);
    }

    public CancelSubscriber(int count) {
        this.count = count;
    }

    @Override
    public void onSubscribe(Subscription subscription) {
        this.subscription = subscription;
        subscription.request(this.count);
    }

    @Override
    public void onNext(T t) {
    }

    @Override
    public void onError(Throwable throwable) {

    }

    @Override
    public void onComplete() {

    }

    public void cancel() {
        this.subscription.cancel();
    }
}
